using System;
using System.Collections.Generic;
using System.Text;
using MyMath;

namespace Physics
{
    class DummyPhysicalTable : StaticBody
    {

        #region IPhysicalObject Members

        public override MyVector Velocity
        {
            get
            {
                return new MyVector(0,0,0);
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public override MyVector AngularVelocity
        {
            get
            {
                return new MyVector(0,0,0);
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public override MyVector Position
        {
            get
            {
                return new MyVector(0, 0, 0);
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }



        public override float BoundingSphereRadius
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }



        public override CollisionDataType CollisionDataType
        {
            get { return CollisionDataType.None; }
        }

        public override ICollisionData CollisionData
        {
            get { return null; }
        }

        public override float CoefficientOfRestitution
        {
            get
            {
                return 1f;
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public override float FrictionCoefficient
        {
            get
            {
                return 1f;
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }
        #endregion
    }
    class DiceTable : ConstrainingObject
    {
        ConstraintGroup group = new ConstraintGroup();
        //ConstrainingMesh mesh;
        public DiceTable(float width,float length,float depth)
        {
            this.PhysicalObject = new DummyPhysicalTable();
            PhysicalObject.Type = ObjectType.Static;
            //mesh = new ConstrainingMesh((CollisionMesh)PhysicalObject.CollisionData);
            //PhysicalObject.CollisionDataType = CollisionDataType.None;

            group.AddObject(new ConstrainingPlane(new MyVector(0, 1, 0), -depth));
            group.AddObject(new ConstrainingPlane(new MyVector(1, 0, 0), -width / 2));
            group.AddObject(new ConstrainingPlane(new MyVector(-1, 0, 0), -width / 2));
            group.AddObject(new ConstrainingPlane(new MyVector(0, 0, 1), -length / 2));
            //group.AddObject(new ConstrainingPlane(new MyVector(0, 0, -1), -length / 2));


        }
        public override bool IntersectSphere(MyVector position, MyVector velocity, CollisionSphere sphere, out MyVector intersectionPoint, out MyVector intersectionNormal, out MyVector translateBack)
        {
            //return group.IntersectSphere(position, velocity, sphere, out intersectionPoint, out intersectionNormal,out translateBack);
            return group.IntersectSphere(position, velocity, sphere, out intersectionPoint, out intersectionNormal, out translateBack);
        }

        public override bool IntersectPoint(MyVector position, MyVector velocity, out MyVector intersectionPoint, out MyVector intersectionNormal, out MyVector translateBack)
        {
            return group.IntersectPoint(position, velocity, out intersectionPoint, out intersectionNormal, out translateBack);
        }
    }
}
